<?php


namespace app\shop\command;


use app\shop\model\order\OrderModel;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\facade\Db;

class Test extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('test')->setDescription('the test command');
    }

    protected function execute(Input $input, Output $output)
    {
//        $output->writeln('no data');
        $maxId = Db::name('message_new')->max('msg_id');
        $list = Db::name('message')->where('msg_id', '>', $maxId)->select();
        foreach ($list as $value) {
            $info = $value;
            if($value['order_id']){
                $orderInfo = OrderModel::withTrashed()->find($value['order_id']);
                if($orderInfo){
                    $chatSign = generate_chat_sign($orderInfo['user_id'], 0, $value['order_id']);
                    $info['chat_sign'] = $chatSign;
                }
            }
            Db::name('message_new')->insert($info);
        }
    }
}